<!DOCTYPE html>
<html>
<head>
    <title>佳怡供应链理财</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

    <meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
">
    <link rel="stylesheet" href="lib/weui.min.css">
    <link rel="stylesheet" href="css/jquery-weui.css">
    <link rel="stylesheet" href="demos/css/demos.css">
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="font/fontscss/iconfont.css">
    <script src="lib/jquery-2.1.4.js"></script>
    <style type="text/css">
        body, html {
            background: #fff;
        }

      /*  .weui-cells {
            margin-top: 2.5rem;
        }*/

        .weui-cell {
            padding: 10px 15px;
        }

        .weui-btn_primary {
            background: #EC991C;
        }

        .weui-btn_primary:not(.weui-btn_disabled):active {
            background: #ec8c22;
        }

        /*.weui-btn_primary:active{
            background: #ec8c22;
        }*/
        .header{
            height: 8rem;
            background: url(demos/images/login-logo@2x.png) no-repeat;
            background-size: 19rem;
        }
        .wjmm{
            margin-left: 14rem;
        }
        .wjmm a{
            color: #4C96E4;
        }

    </style>
</head>
<body>
<div class="header">

</div>
<div class="weui-cells weui-cells_form">
    <form method="post" data-url="/login" id="formlogin">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">账号</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input field-text" type="text" name="username" id="username" placeholder="请输入账号"
                       data-required="true" data-descriptions="username"/>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">密码</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" type="password" name="password" placeholder="请输入密码" id="password"/>
            </div>
        </div>

        <div class="wjmm">
            <a href="sendmail.html">忘记密码？</a>
        </div>
        <div class="weui-btn-area">
            <a class="weui-btn weui-btn_primary" id="conf">登录</a>
            <a href="reg.html" class="weui-btn weui-btn_default">注册</a>

        </div>
        <input type="hidden" name="CSRFToken" id="CSRFToken"  />
    </form>

</div>
<div class="weui-tabbar">

</div>
<script src="lib/fastclick.js"></script>

<script>
    $(function () {
        FastClick.attach(document.body);
        $("#CSRFToken").val(localStorage.getItem("csrf"))
    });
</script>
<script src="js/jquery-weui.js"></script>
<script type="application/javascript">
    $("#conf").click(function () {
        $.ajax({
            type: "POST",
            url: "login/dologin",
            async: false,
            data: $('#formlogin').serialize(),
            success: function (data) {
                console.info(data)
                if (data.users != null && data.users != "") {
                   // $.toast("登录成功");
                    msg = $.parseJSON(data.users);
                    localStorage.setItem("username", msg.username);
                    localStorage.setItem("realname", msg.realname);
                    localStorage.setItem("token", msg.id);
                    localStorage.setItem("member_category",msg.member_category);
                    localStorage.setItem("department_name",msg.department_name+" "+msg.department_name1+" "+msg.department_name2);
                    localStorage.setItem("csrf", data.csrf);
                    setTimeout(function () {
                        $.ajax({
                            url: "user/getMenu",
                            type: "post",
                            async: "false",
                            data: {userid: localStorage.getItem("token")},
                            success: function (msg) {
                                if(msg.length==0){
                                    $.toast("不具备任何权限");
                                }else {
                                    var str = "";
                                    $.each(msg, function (x, y) {
                                        if (y.id == "11") {//投资
                                            $.toast("登录成功");
                                            window.location.href = "touzi.html";
                                            $break;

                                        } else if (y.id == "12") {
                                            $.toast("登录成功");
                                            window.location.href = "approve.html";
                                            $break;
                                        } else if (y.id == "13") {
                                            $.toast("登录成功");
                                            window.location.href = " user.html";
                                            $break;

                                        }

                                    })
                                }
                            }
                        })


                    }, 1000)
                } else {
                    $.toast("用户名或密码错误", "forbidden");
                    $("#username").val("");
                    $("#password").val("");
                    //$("#username").onfocus();
                }
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.toast("登录失败，请检查网络", "forbidden");
            }
        });
    });

</script>
</body>

</html>